#!/bin/bash
echo "创建并编辑一个 systemd 服务单元文件promiscuous-mode.service，用于开机自动开放公共卫生混杂模式，使docker的opt能正常运行"
echo "保存路径：/etc/systemd/system/promiscuous-mode.service"
# 创建并编辑 systemd 服务单元文件
cat << EOF > /etc/systemd/system/promiscuous-mode.service
[Unit]
Description=Set Eth0 Promiscuous Mode On Boot
After=network.target

[Service]
Type=oneshot
ExecStart=/sbin/ip link set eth0 promisc on

[Install]
WantedBy=multi-user.target
EOF

# 重新加载 systemd 配置
sudo systemctl daemon-reload

# 启用服务以在开机时自动启动
sudo systemctl enable promiscuous-mode.service
echo "已创建，重启systemctl"
# 立即启动服务
sudo systemctl start promiscuous-mode.service